package com.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;

import com.bean.PayJson;
import com.bean.PayMessage;
import com.bean.WxPayDto;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ophiux.wechat.utils.Sha1Util;
import com.ophiux.wechat.utils.TenpayUtil;
import com.utils.GetWxOrderno;
import com.utils.PayUtils;
import com.utils.RequestHandler;
import com.utils.http.HttpConnect;
import com.utils.http.HttpResponse;


public class WeChatRichScan extends HttpServlet {

	/**
	 * 文件名称: WeChatRichScan
	 * 内容摘要: 扫一扫支付接口
	 * 创 建 人: zengjian
	 * 创建日期:2016-5-24
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String orderNo = request.getParameter("orderNo"); 	
		String money = request.getParameter("money");
		String code = request.getParameter("code");
		String subMchid = request.getParameter("subMchid");
		String notifyUrl = request.getParameter("notifyUrl");
		if(PayUtils.getOpenId(code)!=null){
			//微信支付jsApi
			WxPayDto tpWxPay = new WxPayDto();
			tpWxPay.setOpenId(PayUtils.getOpenId(code));
			tpWxPay.setBody("预约挂号");
			tpWxPay.setOrderId(orderNo);
			tpWxPay.setSpbillCreateIp(request.getRemoteAddr());
			tpWxPay.setTotalFee(money);
			tpWxPay.setNotifyUrl(notifyUrl);
			tpWxPay.setSubMchid(subMchid);
			PayUtils.getPackage(tpWxPay);
		    
		    //扫码支付
		    WxPayDto tpWxPay1 = new WxPayDto();
		    tpWxPay1.setBody("预约挂号");
		    tpWxPay1.setOrderId(PayUtils.getNonceStr());
		    tpWxPay1.setSpbillCreateIp(request.getRemoteAddr());
		    tpWxPay1.setTotalFee(money);
		    PayUtils.getCodeurl(tpWxPay1);
		}
		
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
